-
-
Notifications
You must be signed in to change notification settings - Fork 23.4k
Remove Object::script
#111323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Object::script
#111323
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This makes sense to me. There's no need for script to be stored twice, especially since the Variant based storage can be less efficient and more error prone than the reference based one.
Would be nice to get another voice from one more GDScript / C# maintainer, but I also don't see huge risks in this. The property has existed since the first commit. It's likely simply no longer needed.
|
We should especially carefully check |
|
I did look at PlaceHolderScriptInstance when making the PR. To me it looks like they are always created with a valid script. Not that familiar with tool mode. What might be a pitfall? Doesn't tool mode create normal script instances? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This looks good to me. I'm glad this is also removing set_script_and_instance() - when working on PR #102373 it was also noted that this method isn't really needed.
There is one potential risk here: if there are any GDExtensions providing scripting languages that depend on the Ref<Script> getting cached on the Godot side, and won't expect get_script() to get called so often. However, I think at worst this would be a performance issue, and not one that breaks compatibility? So, I think it should be fine
|
It could be compat breaking for an implementation that tries to obtain the script from the Still it technically breaks compat in a way that should at least be documented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me too, great catch! Even if we encounter some regression, we can always fix it or revert the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C# changes look good to me.
|
Regarding tool mode, I did try this with my kanban board addon and on a cursory look everything seems to work alright. |
|
Thanks! |
Removes 24 bytes from
Objectsince the script was stored asVariant. Instead obtains the script from theScriptInstance.As far as I can see
Object::get_scriptis not used in any obvious hot paths, so the additional overhead should not matter that much.In addition to making object smaller, this is also makes inconsistent states impossible.